var dmc = urlFilename.substring(0, urlFilename.indexOf("_"));
var baseApi = parent.parent.IP;
var PREFIX = sessionStorage.getItem("PREFIX");
/* 初始化显示备注信息 */
initRelation();

function guid() {
    var mm = Math.random();
    var six = "";
    if (mm > 0.1) {
        six = Math.round(mm * 1000000);
    } else {
        mm += 0.1;
        six = Math.round(mm * 1000000);
    }
    return six;
}


function initRelation() {
    console.log("开始调用关联数据推送")
    // /gjbDateModel/getDateModelByRelation
    // /padDateModel/getDateModelByRelation
    var url = baseApi + PREFIX + "DateModel/getDateModelByRelation?t=" + (new Date()).getTime();
    $.ajax({
        type: "GET", url: url, data: {
            "dmc": dmc,
        }, dataType: "JSON", success: function (res) {
            if (res.resp_code == '0') {
                var data = res.datas;
                if (data.length > 0) {
                    var relationHtml = "";
                    if ($("#DmMedialist").children().length == 0) {
                        relationHtml = '<div class="relation"><span class="relationSpan">相关内容推送</span></div><div class="relationTitle" >';
                        for (var i = 0; i < data.length; i++) {
                            var random = guid();
                            var html = `
								<span class="relationSpan" id=${data[i].id} onclick="dmRefLink('${data[i].dmc}')">${data[i].infoName}</span>
							`
                            relationHtml += html;
                        }
                    } else {
                        relationHtml = '<div class="relation" style="margin-left: 10%;    color: #fff"><span class="relationSpan">相关内容推送</span></div><div class="relationTitle"   style="margin-left: 13%;">';
                        for (var i = 0; i < data.length; i++) {
                            var random = guid();
                            var html = `
								<span class="relationSpan" id=${data[i].id} onclick="dmRefLink('${data[i].dmc}')">${data[i].infoName}</span>
							`
                            relationHtml += html;
                        }
                    }
                    relationHtml += '</div>';
                    $("body").append(relationHtml);
                }
            }
        }
    })
}
